package com.lzwk.app.ods.mdb;

import com.lzwk.common.mdb.MDBConstant;
import org.apache.flink.table.api.TableResult;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @title: MdbJDBCTables
 * @Author Yeaser
 * @Date: 2022/3/1 18:24
 * @Version 1.0
 * Description: TODO
 */
public class MdbJDBCTables {
    public static void mdbAccountAccount(StreamTableEnvironment tenv){

        tenv.executeSql(" CREATE TABLE mdb_account_account ( " +
                " id int, " +
                " create_time timestamp , " +
                " openid string , " +
                " active_ip string , " +
                " active_time timestamp, " +
                " nickname string, " +
                " headimgurl string, " +
                " sex string, " +
                " country string, " +
                " province string, " +
                " city string, " +
                " telephone string , " +
                " status string , " +
                " subscribed int, " +
                " introduction string, " +
                " role string, " +
                " unionid string , " +
                " is_robot tinyint, " +
                " address string, " +
                " is_vip tinyint, " +
                " mobile_openid string , " +
                " name string, " +
                " pc_openid string ," +
                " device_token string , " +
                " wechat string , " +
                " wxa_openid string , " +
                " register_source string, " +
                " webo_uid string, " +
                " `proc_time` AS PROCTIME(), " +
                "  PRIMARY KEY (`id`) NOT ENFORCED" +
                ") with ( " +
                "  'connector' = 'jdbc', " +
                "  'driver' = 'com.mysql.cj.jdbc.Driver', " +
                "  'url'='jdbc:mysql://" + MDBConstant.MDBSLAVEHOST + ":" + MDBConstant.MDBSLAVEPORT + "/" + MDBConstant.MDBSLAVEDBNAME + "?characterEncoding=utf8&serverTimezone=Asia/Shanghai&autoReconnect=true&tinyInt1isBit=false&transformedBitIsBoolean=false', " +
                "  'table-name' = " + "'" + MDBConstant.MDBJDBCACCOUNTACCOUNT + "'" + ", " +
                "  'username'=" + "'" + MDBConstant.MDBSLAVEUSERNAME + "'" + ", " +
                "  'password'=" + "'" + MDBConstant.MDBSLAVEPASSWORD + "'" + ", " +
                "  'lookup.cache.max-rows'='2000', " +
                "  'lookup.cache.ttl'='600000' " +
                ")");

    }
}
